package com.niit.dao.impl;

import com.niit.dao.INoticeDao;
import com.niit.domain.Notice;
import com.niit.utils.DBHelper;

import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;

public class NoticeDaoImpl implements INoticeDao {
    @Override
    public Notice queryNotice() {
        Notice notice=null;
        String sql="select * from sh_notice order by ctime desc limit 1";
        ResultSet rs= DBHelper.executeQuery(sql);
        try {
            if(rs.next()){
                Integer id= rs.getInt(1);
                String content=rs.getString(2);
                Date ctime=rs.getDate(3);
                notice=new Notice(id,content,ctime);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return notice;
    }
}
